<script setup lang="ts">
import { TrayIcon } from '@tauri-apps/api/tray';
import { onMounted, onUnmounted } from 'vue';
import { useI18n } from 'vue-i18n';

import SystemTray from '@/shared/services/system-tray';

const { t } = useI18n();

onMounted(initSystemTray);
onUnmounted(closeSystemTray);

let systemTray: TrayIcon | null;

async function initSystemTray(): Promise<void> {
  systemTray = await SystemTray.getTrayWithMenu({
    exitText: t('exit'),
  });
}

function closeSystemTray(): void {
  systemTray?.close();
  systemTray = null;
}
</script>

<template>
  <router-view />
</template>

<style scoped></style>
